/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

@Entity  
public class Appointment implements Serializable {
    
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO) //create prymary key id
    @Column(nullable = false)
    private Long id;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date datte;
    @Column(nullable = false)
    private int charge;
    @Column(nullable = false)
    private String notes;

    public Date getDatte() {
        return datte;
    }

    public int getCharge() {
        return charge;
    }

    public String getNotes() {
        return notes;
    }

    public Veterinarian getVeterinarian() {
        return veterinarian;
    }

    public MedicalRecord getMedicalRecord() {
        return medicalRecord;
    }
    
    @ManyToOne
    private Veterinarian veterinarian;  //Many appointment has One veterinarian 
    
    @ManyToOne
    @JoinColumn(name = "MedicalRecord_fk")
    private MedicalRecord medicalRecord; //Many appointment has One medical medicalRecord
   
    
    public Appointment(Date datte, int charge, String notes, Veterinarian veterinarian, MedicalRecord record) {
        this.datte = datte;
        this.charge = charge;
        this.notes = notes;
        this.veterinarian = veterinarian;
        this.medicalRecord = record;
    }
      
    public Appointment(){
        this.datte = null;
        this.charge = 0;
        this.notes = "nothing to say";
        this.veterinarian =null;
        this.medicalRecord = null;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }    
    
    @Override
    public String toString(){
        return "Appointment Day: "+datte+"-"+charge+"-"+notes+"\n";
    }
}
